package cn.szzsi.common.model;

import cn.szzsi.common.kit.CommonUtil;
import cn.szzsi.common.model.base.BaseCustomerDividend;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * Created by zhengy on 2017/2/11.
 */
//@TableBind(tableName = "b_customer_dividend",pkName = "id")
public class CustomerDividend extends BaseCustomerDividend<CustomerDividend> {
    public static final CustomerDividend dao=new CustomerDividend().dao();

    public List<CustomerDividend> isExit(Integer dataLevel, String createDate, String uid){
        return CustomerDividend.dao.find("select id from mall_customer_dividend where dataLevel=? and profitDate=? and uid=?",dataLevel,createDate,uid);
    }

    /**
     * 生成分红记录
     * @param mid
     * @param rewardnum
     * @param profit
     * @param status
     * @param dataLevel
     * @param uid
     * @param profitDate
     */
    public static void saveInfo(String mid, Long rewardnum, BigDecimal profit, Integer status, Integer dataLevel, String uid, String profitDate){
        CustomerDividend dividend=new CustomerDividend();
        dividend.set("id", CommonUtil.getUUID());
        dividend.set("mid",mid);
        dividend.set("rewardnum",rewardnum);
        dividend.set("profit",profit);
        dividend.set("status",status);
        dividend.set("dataLevel",dataLevel);
        dividend.set("uid",uid);
        dividend.set("profitDate",profitDate);
        dividend.set("createDate",new Date());
        dividend.save();

    }
}
